/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tramite.bc;

import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.persistence.NoResultException;
import org.cip.esymons.colegiatura.bc.ColegiadoFacadeLocal;
import org.cip.esymons.colegiatura.be.Colegiado;

/**
 *
 * @author ChristianATE
 */
public class ColegiadoDelegate {
    
    private ColegiadoFacadeLocal local;

    public ColegiadoDelegate() {
        local=lookupColegiadoFacade();
    }

    public Colegiado buscaPorCip(String cip){        
        return local.colegiadoPersona(cip);        

    }

    public Colegiado buscar(Long id){
        return local.find(id);

    }

    public Colegiado colegiadoPersonaDNI(String dni) {
        return local.buscarColegiadoXDni(dni);
    }

    public void edit(Colegiado colegiado){
        local.edit(colegiado);
    }

    public Colegiado colegiadoPersona(String nroCip){
        return local.colegiadoPersona(nroCip);
    }

    public busqColXCip.Colegiado wsBuscarColegiadoxCIP(int cip) {
        return local.wsBuscarColegiadoxCIP(cip);
    }

    private ColegiadoFacadeLocal lookupColegiadoFacade() {
        try {
            Context c = new InitialContext();
            return (ColegiadoFacadeLocal) c.lookup("java:comp/env/ColegiadoFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }



}
